function formatDate(now) {
  var y, m, d;
  (y = now.getFullYear()), (m = now.getMonth() + 1), (d = now.getDate());
  return (
    y +
    '/' +
    (m < 10 ? '0' + m : m) +
    '/' +
    (d < 10 ? '0' + d : d) +
    ' ' +
    now.toTimeString().substr(0, 8)
  );
}

String.prototype.format = function (args) {
    var result = this;
    if (arguments.length < 1) {
        return result;
    }

    var data = arguments; //如果模板参数是数组
    if (arguments.length == 1 && typeof args === 'object') {
        //如果模板参数是对象
        data = args;
    }
    for (var key in data) {
        var value = data[key];
        if (undefined != value) {
            result = result.replace('{' + key + '}', value);
        }
    }
    return result;
};

export {formatDate};
